#include<iostream>
using namespace std;
int min(int left,int right){
    if(left>right)
        return right;
    if(left<right)
        return left;
}
int max(int left,int right){
 if(left<right)
        return right;
    if(left>right)
        return left;
}
int Find_min(int A[],int left,int right){        //找最小金块
    int left_a, right_a, middle_a;
    if(left==right){       //只有一个数字
        int min;
        min = A[left];
        return min;
            }
    if(right-1==left)           //只有两个数字
    {
        left_a = A[left];
        right_a = A[right];
        return (min(left_a, right_a));
    }
    if(right-left>1){
        middle_a = (left + right) / 2;
        left_a = Find_min(A, left, middle_a);
        right_a = Find_min(A, middle_a, right);
        return (min(left_a, right_a));
    }
}
int Find_max(int A[],int left,int right)  //寻找最重金块的函数
{   
    int left_a,middle_a,right_a;   
    if(left==right)
    {    
        int max;    
        max=A[right];    
        return max;   
    }    
    if(right-left==1)    
    {    
        left_a=A[left];    
        right_a=A[right];    
        return(max(left_a,right_a));     
    }      
    if(right-left>1)
    {       
        middle_a=(left+right)/2;      
        left_a=Find_max(A,left,middle_a);      
        right_a=Find_max(A,middle_a,right);      
        return(max(left_a,right_a));     
    }       
}   
int main(){
    int n, i;
    int a[100];
    cout << "请输入金块的总块数n:" << endl;
    cin >> n;
    for (i = 0; i < n;i++)
    {
        int k;
        cin >> k;
        a[i] = k;
    }
    cout << "最重的金块为：" << Find_max(a, 0, n-1) << endl;
    cout << "最轻的金块为：" << Find_min(a, 0, n-1) << endl;
    return 0;
}